﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.BusinessData.MetadataModel;
using Microsoft.BusinessData.MetadataModel.Collections;

namespace MsExchangeBcsConnector.ExchangeBdcModel.Helpers
{
    internal static class LobSystemInstanceHelper
    {

        /// <summary>
        /// Return value from LOB system settings
        /// </summary>
        /// <param name="PropertyName"></param>
        /// <returns></returns>
        internal static string GetPropertyValue(ILobSystemInstance LobSystemInstance, string PropertyName)
        {
            INamedPropertyDictionary props = LobSystemInstance.GetProperties();
            if (props.ContainsKey(PropertyName))
                return props[PropertyName].ToString();
            else
                return string.Empty;
        }

        internal static string MailboxDisplayUrlPattern(ILobSystemInstance LobSystemInstance)
        {
            return LobSystemInstanceHelper.GetPropertyValue(LobSystemInstance, Constants.MailboxDisplayUrlPattern);
        }


        internal static string MessageDisplayUrlPattern(ILobSystemInstance LobSystemInstance)
        {
            return LobSystemInstanceHelper.GetPropertyValue(LobSystemInstance, Constants.MessageDisplayUrlPattern);
        }


        internal static string ExchangeServiceUrl(ILobSystemInstance LobSystemInstance)
        {
            return LobSystemInstanceHelper.GetPropertyValue(LobSystemInstance, Constants.ExchangeServiceUrlPropertyName);
        }

        internal static string ExchangeLogin(ILobSystemInstance LobSystemInstance)
        {
            return LobSystemInstanceHelper.GetPropertyValue(LobSystemInstance, Constants.ExchangeLoginPropertyName);
        }

        internal static string ExchangePassword(ILobSystemInstance LobSystemInstance)
        {
            return LobSystemInstanceHelper.GetPropertyValue(LobSystemInstance, Constants.ExchangePasswordPropertyName);
        }

        internal static string EmailDomainForCrawling(ILobSystemInstance LobSystemInstance)
        {
            return LobSystemInstanceHelper.GetPropertyValue(LobSystemInstance, Constants.EmailDomainForCrawlingPropertyName);
        }


        internal static string ProfileSiteUrl(ILobSystemInstance LobSystemInstance)
        {
            return LobSystemInstanceHelper.GetPropertyValue(LobSystemInstance, Constants.ProfileSiteUrlPropertyName);
        }

        internal static string AdministratorSecurityGroup(ILobSystemInstance LobSystemInstance)
        {
            return LobSystemInstanceHelper.GetPropertyValue(LobSystemInstance, Constants.AdministratorSecurityGroupPropertyName);
        }
    }
}
